<%@ page language="java"  contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>便民医疗服务系统登录</title>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<link rel="shortcut icon" href="../assets/images/logo.png" type="image/x-icon" />
		<link rel="stylesheet" href="../assets/layui/css/layui.css">
		<script src="../assets/layer/layer.js"></script>
		<script src="../assets/layui/layui.js"></script>
		<link rel="stylesheet" href="../assets/css/login.css">

	
	</head>

	<body>
		
		<div class="layui-carousel video_mask" id="login_carousel">
			<div carousel-item>
				<div class="carousel_div1"></div>
				<div class="carousel_div2"></div>
				<div class="carousel_div3"></div>
			</div>
			<div class="login layui-anim layui-anim-up">
				<div class="layui-logo">
				</div>
				<fieldset class="layui-elem-field layui-field-title">
					<legend class="text-white">便民医疗服务系统登录</legend>
				</fieldset>
				<div class="layui-form" action="" method="post">
					<div class="layui-form-item">
			
						<input type="text" id="account" name="account" lay-verify="required|account" maxlength="20" placeholder="请输入手机号" autocomplete="off" autofocus="autofocus" class="layui-input"><div id="accountStatus" style="color:#0c0"></div>
					</div>
					<div class="layui-form-item">
						<input type="password" id="password" name="password" lay-verify="required" maxlength="20" placeholder="请输入密码" autocomplete="off" class="layui-input">
					</div>						
					 <div style="width:100px;">
		        	<select id="role" name="role" >
					<option value="pat" >病人</option>
					 	<option value="doc">医生</option>
					 </select>
		        </div>	
				</div>
				<hr class="layui-bg-gray">
		        		<button id="login" class="login_btn layui-btn layui-btn-radius layui-btn-normal" >登录</button>
				<div class="layui-footer text-white">
					
					<strong class="text-white">还没有账号？ <a href="register.jsp" style="color: cornflowerblue;">立即注册&raquo;</a></strong>
				</div>
			</div>
		</div>
 		
 		<script type="text/javascript" src="../assets/js/jquery.min.js"></script>
		<script type="text/javascript" src="../assets/layui/layui.all.js"></script>
		<script type="text/javascript" src="../assets/js/login.js"></script>
		<script type="text/javascript">
   $(function(){
	   //点击登录按钮触发的事件 
	   $("#login").click(function(){
		   //ajax请求 
		   $.ajax({
			   url:'../getUserlogin?userloginid='+$("#account").val()+'&userpwd='+$("#password").val()+'&userType='+$("#role").val(),
			   type:'get',
			   success:function(result){
				   if (result.indexOf("success/patient")==0) {//病人登录成功，跳转到病人主页面 
					   layer.msg('登录成功~', {
							icon: 6
							
						}, function(){
							location.href="${pageContext.request.contextPath}/front/index.jsp";
						});
						
					} else if(result.indexOf("success/doctor")==0){//医生登录成功，跳转到医生主页面 
						layer.msg('登录成功~', {
							icon: 6
						
						}, function(){
							
							location.href="${pageContext.request.contextPath}/doctor1/"+result.substring(14)+"?url=forward:/front/doctor-personal.jsp";
						});
						
					}else{//登录失败，刷新页面 
						layer.msg('登录失败~', {
 							icon: 5
 					
 						}, function(){
 							location.reload();
						});
						
				}
			   }
		   });
	   });
   });
  </script>
	</body>       
</html>